package com.biShe.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebCrossConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry){
        registry.addMapping("/**")//允许访问的后台路径
                .allowedOrigins("http://localhost:8081/")//前端的访问路径
                .allowedMethods("GET","POST","DELETE","OPTION","PUT")//允许使用的方法
                .allowCredentials(true)//允许携带参数
                .allowedOriginPatterns("*")
                .maxAge(7200);//最大响应时间
    }
}
